<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Wavelet Transforms</title>
<link rel="stylesheet" href="../math.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../index.html" title="Math Toolkit 4.2.1">
<link rel="up" href="../quadrature.html" title="Chapter 14. Quadrature and Differentiation">
<link rel="prev" href="naive_monte_carlo.html" title="Naive Monte Carlo Integration">
<link rel="next" href="diff.html" title="Numerical Differentiation">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
<td align="center"><a href="../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="naive_monte_carlo.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../quadrature.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="diff.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="math_toolkit.wavelet_transforms"></a><a class="link" href="wavelet_transforms.html" title="Wavelet Transforms">Wavelet Transforms</a>
</h2></div></div></div>
<h4>
<a name="math_toolkit.wavelet_transforms.h0"></a>
      <span class="phrase"><a name="math_toolkit.wavelet_transforms.synopsis"></a></span><a class="link" href="wavelet_transforms.html#math_toolkit.wavelet_transforms.synopsis">Synopsis</a>
    </h4>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">quadrature</span><span class="special">/</span><span class="identifier">wavelet_transforms</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>

<span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">quadrature</span> <span class="special">{</span>

<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">F</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">Real</span><span class="special">,</span> <span class="keyword">int</span> <span class="identifier">p</span><span class="special">&gt;</span>
<span class="keyword">class</span> <span class="identifier">daubechies_wavelet_transform</span>
<span class="special">{</span>
<span class="keyword">public</span><span class="special">:</span>
    <span class="identifier">daubechies_wavelet_transform</span><span class="special">(</span><span class="identifier">F</span> <span class="identifier">f</span><span class="special">,</span> <span class="keyword">int</span> <span class="identifier">grid_refinements</span> <span class="special">=</span> <span class="special">-</span><span class="number">1</span><span class="special">,</span> <span class="identifier">Real</span> <span class="identifier">tol</span> <span class="special">=</span> <span class="number">100</span><span class="special">*</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">numeric_limits</span><span class="special">&lt;</span><span class="identifier">Real</span><span class="special">&gt;::</span><span class="identifier">epsilon</span><span class="special">(),</span>
    <span class="keyword">int</span> <span class="identifier">max_refinements</span> <span class="special">=</span> <span class="number">12</span><span class="special">)</span> <span class="special">{}</span>

    <span class="identifier">daubechies_wavelet_transform</span><span class="special">(</span><span class="identifier">F</span> <span class="identifier">f</span><span class="special">,</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">daubechies_wavelet</span><span class="special">&lt;</span><span class="identifier">Real</span><span class="special">,</span> <span class="identifier">p</span><span class="special">&gt;</span> <span class="identifier">wavelet</span><span class="special">,</span> <span class="identifier">Real</span> <span class="identifier">tol</span> <span class="special">=</span> <span class="number">100</span><span class="special">*</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">numeric_limits</span><span class="special">&lt;</span><span class="identifier">Real</span><span class="special">&gt;::</span><span class="identifier">epsilon</span><span class="special">(),</span>
    <span class="keyword">int</span> <span class="identifier">max_refinements</span> <span class="special">=</span> <span class="number">12</span><span class="special">);</span>

    <span class="keyword">auto</span> <span class="keyword">operator</span><span class="special">()(</span><span class="identifier">Real</span> <span class="identifier">s</span><span class="special">,</span> <span class="identifier">Real</span> <span class="identifier">t</span><span class="special">)-&gt;</span><span class="keyword">decltype</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">declval</span><span class="special">&lt;</span><span class="identifier">F</span><span class="special">&gt;()(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">declval</span><span class="special">&lt;</span><span class="identifier">Real</span><span class="special">&gt;()))</span> <span class="keyword">const</span><span class="special">;</span>

<span class="special">};</span>
<span class="special">}</span>
</pre>
<p>
      The wavelet transform of a function <span class="emphasis"><em>f</em></span> with respect to
      a wavelet ψ is
    </p>
<p>
      <span class="inlinemediaobject"><object type="image/svg+xml" data="../../graphs/wavelet_transform_definition.svg" width="333" height="48"></object></span>
    </p>
<p>
      For compactly supported Daubechies wavelets, the bounds can always be taken
      as finite, and we have
    </p>
<p>
      <span class="inlinemediaobject"><object type="image/svg+xml" data="../../graphs/daubechies_wavelet_transform_definition.svg" width="328" height="44"></object></span>
    </p>
<p>
      which also defines the <span class="emphasis"><em>s</em></span>=0 case.
    </p>
<p>
      The code provided by Boost merely forwards a lambda to the trapezoidal quadrature
      routine, which converges quickly due to the Euler-Maclaurin summation formula.
      However, the convergence is not as rapid as for infinitely differentiable functions,
      so the default tolerances are modified.
    </p>
<p>
      A basic usage is
    </p>
<pre class="programlisting"><span class="keyword">auto</span> <span class="identifier">psi</span> <span class="special">=</span> <span class="identifier">daubechies_wavelet</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">,</span> <span class="number">8</span><span class="special">&gt;();</span>
<span class="keyword">auto</span> <span class="identifier">f</span> <span class="special">=</span> <span class="special">[](</span><span class="keyword">double</span> <span class="identifier">x</span><span class="special">)</span> <span class="special">{</span>
    <span class="keyword">return</span> <span class="identifier">sin</span><span class="special">(</span><span class="number">1</span><span class="special">/</span><span class="identifier">x</span><span class="special">);</span>
<span class="special">};</span>
<span class="keyword">auto</span> <span class="identifier">Wf</span> <span class="special">=</span> <span class="identifier">daubechies_wavelet_transform</span><span class="special">(</span><span class="identifier">f</span><span class="special">,</span> <span class="identifier">psi</span><span class="special">);</span>

<span class="keyword">double</span> <span class="identifier">w</span> <span class="special">=</span> <span class="identifier">Wf</span><span class="special">(</span><span class="number">0.8</span><span class="special">,</span> <span class="number">7.2</span><span class="special">);</span>
</pre>
<p>
      An image from this function is shown below.
    </p>
<p>
      <span class="inlinemediaobject"><img src="../../graphs/scalogram_sin1t_light.png"></span>
    </p>
</div>
<div class="copyright-footer">Copyright © 2006-2021 Nikhar Agrawal, Anton Bikineev, Matthew Borland,
      Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert Holin, Bruno
      Lalande, John Maddock, Evan Miller, Jeremy Murphy, Matthew Pulver, Johan Råde,
      Gautam Sewani, Benjamin Sobotta, Nicholas Thompson, Thijs van den Berg, Daryle
      Walker and Xiaogang Zhang<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
      </p>
</div>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="naive_monte_carlo.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../quadrature.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="diff.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
